clear all; clc; close all
j = 0;
w0 = 2*pi*3e6;
Bw = 2*pi*1500e3;
for n = [1 3 5]
j = j + 1;
[z, p, k] = buttap(n);
[b, a] = zp2tf(z, p, k);
[b_new, a_new] = lp2bp(b, a, w0, Bw);
[Hn, wn] = freqs(b_new, a_new);
H(:, j) = Hn; w(:, j) = wn;
end
Fd = 44.2e6/4; Td = 1/Fd;
tmax = 0.001; t = 0:Td:tmax;
N_PRN = 511; T_PRN = 0.001;
PRN = sign(randn(1, N_PRN));
ind_h = fix(mod(t/T_PRN, 1)*N_PRN) + 1;
h = PRN(ind_h);
A = 2;
f0 = 3e6;
phi = pi/4;
u = A * h .* cos(2*pi*f0*t + phi);
[bz,az]=impinvar(b_new, a_new, Fd);
c=fft(u);
s=filter(bz,az,u);
v=fft(s);
figure (1)
plot(w/2/pi, abs(H));
xlabel('f, Hz');
ylabel('|H(j\omega)|');
legend('n=1','n=3','n=5');
figure (2)
plot(20*log10(abs(c)))
hold on
plot(20*log10(abs(v)),'r')
grid on